<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

/**
 * Class CreateDormMetersTable.
 */
class CreateDormMetersTable extends Migration
{
	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::create('dorm_meters', function(Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('dorm_id');
            $table->unsignedInteger('meter_type_id');
            $table->string('nfc_id')->unique();
            $table->double('last_reading',10,2)->nullable();
            $table->date('last_reading_date');
            $table->string('unit',10)->default('计量单位');
            $table->boolean('active')->default(true);
            $table->timestamp('created_at')->useCurrent();
            $table->timestamp('updated_at')->useCurrent();
		});
	}

	/**
	 * Reverse the migrations.
	 *
	 * @return void
	 */
	public function down()
	{
		Schema::drop('dorm_meters');
	}
}
